IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spTsetup_Create')
	BEGIN
		PRINT 'Dropping Procedure spTsetup_Create'
		DROP  Procedure  spTsetup_Create
	END

GO

PRINT 'Creating Procedure spTsetup_Create'
GO
CREATE Procedure dbo.spTsetup_Create
	( 	  
	  @MAXDAYS decimal = null, 
		@MAXREQ decimal = null, 
		@SENDMAIL bit = null, 
		@SMTPIP char(16) = null, 
		@SENDEREMAIL char(40) = null, 
		@SENDERNAME char(40) = null, 
		@SENDSTSERR bit = null, 
		@SENDSTSTO char(80) = null, 
		@RETWARN bit = null, 
		@PICKFOLDER decimal = null, 
		@QCLETBODY text = null, 
		@ORDERNO int = null, 
		@ORDERTOEMAIL char(40) = null
	)
AS
  /* 
    ------------------------------------------------------------------------------
    - Change History
    - --------------
    - Date          Description
    ------------------------------------------------------------------------------
    - 8/29/2007    Initial version created
    ------------------------------------------------------------------------------
  */

	-- Declare the required variables

	-- Create the required new record
	INSERT INTO Tsetup
	  (
		MAXDAYS,
			MAXREQ,
			SENDMAIL,
			SMTPIP,
			SENDEREMAIL,
			SENDERNAME,
			SENDSTSERR,
			SENDSTSTO,
			RETWARN,
			PICKFOLDER,
			QCLETBODY,
			ORDERNO,
			ORDERTOEMAIL	  
	  )
	VALUES
	  (
		@MAXDAYS,
			@MAXREQ,
			@SENDMAIL,
			@SMTPIP,
			@SENDEREMAIL,
			@SENDERNAME,
			@SENDSTSERR,
			@SENDSTSTO,
			@RETWARN,
			@PICKFOLDER,
			@QCLETBODY,
			@ORDERNO,
			@ORDERTOEMAIL
	  )

	-- Handle any errors
	IF @@ERROR != 0
	BEGIN
		RAISERROR('spTsetup_Create: Unable to Insert a new Tsetup', 10, 1)
		RETURN
	END

	-- Return the newly created ID
	SELECT	@@IDENTITY AS 'Tsetup_ID'

	-- Return to calling method
	RETURN 

GO
